<template>
    <Cascader :data="cityData" v-model="cityCodeArray" @on-change="finishPick"></Cascader>
</template>
<script>
    import addressData from './addressData';

    export default {
        name: 'cascaderAddress',
        props:{
            cascaderValue:{
                type:Array,
                default: () => {
                    return [];
                }
            }
        },
        data() {
            return {
                cityData: addressData,
                cityCodeArray:[]
            };
        },
        methods: {
            finishPick(value, selectedData) {
                this.cityCodeArray = selectedData;
            }
        },
        watch: {
            cityCodeArray(val) {
                this.$emit('cascaderPick', val);
            },
            cascaderValue(val){
                this.cityCodeArray = val;
            }
        }
    };
</script>